#!/bin/bash

# 定义容器名称
CONTAINER_NAME="zhuang_xian1"

# 检查容器是否存在，如果存在则删除
if docker ps -a --format '{{.Names}}' | grep -q "^${CONTAINER_NAME}$"; then
    echo "Container ${CONTAINER_NAME} exists, stopping and removing it..."
    docker stop ${CONTAINER_NAME} > /dev/null 2>&1 || true
    docker rm ${CONTAINER_NAME} > /dev/null 2>&1 || true
else
    echo "No existing container named ${CONTAINER_NAME}"
fi

# 启动新的容器     # --device=/dev/video0:/dev/video0 \
docker run --name ${CONTAINER_NAME} \
    --shm-size=32g \
    --gpus='all' \
    --log-opt max-size=100m \
    --log-opt max-file=2 \
    --rm \
    -ti \
    --network host \
    -v $(pwd):/workspace/zhty_triton \
    -w /workspace/zhty_triton \
    zhty_triton:v4.1 \
    /bin/bash -c "
        # 在容器内要执行的命令序列
        python3 flask_server.py --server_port 5000
    "